package com.etime.perfectschool.controller;

import com.etime.perfectschool.pojo.NewsComments;
import com.etime.perfectschool.service.NewsCommentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class NewsCommentsController {
    @Autowired
    private NewsCommentsService newsCommentsService;
    @GetMapping("/newsComments")
    public List<NewsComments> getAllNewsComments(int newsId)
    {
       return newsCommentsService.getAllNewsComments(newsId);
    }
    //评论
    @PostMapping("/addNewsComments")
    public int addNewsComments(NewsComments newsComments)
    {
      return  newsCommentsService.addNewsComments(newsComments);
    }
    //    删除某条新闻的全部评论
    @DeleteMapping("/deleteNewsCommentsBynewId")
    public boolean deleteNewsCommentsBynewId(int newsId)
    {
        return newsCommentsService.deleteNewsCommentsBynewId(newsId);
    }
}
